package com.taotao.tools.jackson.constant;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * <p>
 *  根据mysql类型的设置默认值
 * </p>
 *
 * @author youbeiwuhuan
 * @version 1.0.0
 * @date 2023/11/1 12:35
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DefaultValue {


    public static final Set<Class<?>> int_class= newHashSet(byte.class, Byte.class,short.class,Short.class,int.class,Integer.class,long.class,Long.class);

    /**
     * 对应 byte/int/long/short 等及其包装类
     *
     */
    public static final String int_null= "0";

    public static final Set<Class<?>> decimal_class= newHashSet(float.class,Float.class,double.class,Double.class, BigDecimal.class);
    /**
     * 对应float/double及其包装类和BigDecimal
     *
     */
    public static final String decimal_null= "0";
    /**
     * 对弈String
     *
     */
    public static final String string_null= "";


    // mysql 时间日期推荐设置默认值为零值（0000-00-00或0000-00-00 00:00:00）;jdbc配置zeroDateTimeBehavior=convertToNull；mysql sql-mode配置中删除NO_ZERO_IN_DATE,NO_ZERO_DATE；
    public static final Set<Class<?>> date_class= newHashSet( LocalDate.class);
    /**
     * 对应LocalDate,mysql的date
     */
    public static final String date_null="1000-01-01";

    public static final Set<Class<?>> datetime_class= newHashSet(Date.class, LocalDateTime.class);

    /**
     * 对应LocalDateTime/Date,mysql的timestamp/datetime
     */
    public static final String datetime_null= "1970-01-01 00:00:01";
    public static final Set<Class<?>> localtime_class= newHashSet(LocalTime.class);
    /**
     * LocalTime
     */
    public static final String localtime_null= "00:00:00";


    public static final String date_parttern = "yyyy-MM-dd";
    public static final String datetime_parttern = "yyyy-MM-dd HH:mm:ss";
    public static final String localtime_parttern = "HH:mm:ss";

    public static <E> HashSet<E> newHashSet(E... elements) {
        HashSet<E> set = new HashSet<>(elements.length);
        Collections.addAll(set, elements);
        return set;
    }
}
